using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace ExperimentManager {
  class Critic {
    public static List<TrainingExample> GetTrainingExamples(string logFileName) {
      List<TrainingExample> trainingExamples = new List<TrainingExample>();

      // nacte zaznam partie
      XmlDocument doc = new XmlDocument();
      doc.Load(logFileName);

      // vytvori treninkove priklady
      foreach (XmlNode move in doc.GetElementsByTagName("move")) {
        TrainingExample te = new TrainingExample(6);
        te.fitnessComponents[0] = int.Parse(move.SelectSingleNode("fitnessComponents/x1").InnerText);
        te.fitnessComponents[1] = int.Parse(move.SelectSingleNode("fitnessComponents/x2").InnerText);
        te.fitnessComponents[2] = int.Parse(move.SelectSingleNode("fitnessComponents/x3").InnerText);
        te.fitnessComponents[3] = int.Parse(move.SelectSingleNode("fitnessComponents/x4").InnerText);
        te.fitnessComponents[4] = int.Parse(move.SelectSingleNode("fitnessComponents/x5").InnerText);
        te.fitnessComponents[5] = int.Parse(move.SelectSingleNode("fitnessComponents/x6").InnerText);

        te.fitnessTotal = int.Parse(move.SelectSingleNode("fitnessTotal").InnerText);

        trainingExamples.Add(te);
      }

      return trainingExamples;
    }
  }
}
